package com.joysuch.wwyt.core.enums;

import com.joysuch.wwyt.core.common.util.ErrorCheck;

import java.io.Serializable;

public class StateEnum implements Serializable {

    private static final long serialVersionUID = 1554591908156654711L;

    /**
     * Stream视频流的类型
     */
    public enum StreamType {

        ON_PUBLISH("on_publish", "推流"),
        ON_UNPUBLISH("on_unpublish", "关流");

        private final String value;
        private final String text;

        private StreamType(String value, String text) {
            this.value = value;
            this.text = text;
        }

        public String getValue() {
            return value;
        }

        public String getText() {
            return text;
        }

        public static Boolean checkStatus(Object param, boolean throwError) {
            if (throwError) {
                ErrorCheck.check(param == null, "参数: status为空");
                boolean notExist = true;
                for (StreamType o : values()) {
                    if (param.toString().toLowerCase().equals((o.getValue() + "").toLowerCase())) notExist = false;
                }
                ErrorCheck.check(notExist, "参数: status传值错误");
            }
            if (values().length == 0) return false;
            for (StreamType o : values()) {
                if (param.toString().toLowerCase().equals((o.getValue() + "").toLowerCase())) return true;
            }
            return false;
        }
    }

    /**
     * 视频编码格式，指定编码类型
     */
    public enum VideoCodecEnum {

        H265("H265", "H265编码格式"),
        H264("H264", "H264编码格式");

        private String value;
        private String text;

        VideoCodecEnum(String value, String text) {
            this.value = value;
            this.text = text;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }

        public String getText() {
            return text;
        }

        public void setText(String text) {
            this.text = text;
        }
    }

    /**
     * 播放类型
     */
    public enum PlayTypeEnum {

        LIVE("live", "实时流"),
        HISTORY("history", "历史流");

        private String value;
        private String text;

        PlayTypeEnum(String value, String text) {
            this.value = value;
            this.text = text;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }

        public String getText() {
            return text;
        }

        public void setText(String text) {
            this.text = text;
        }
    }

}
